package com.company.calendar.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.calendar.entity.WorkdayConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 工作日配置Mapper接口
 * 
 * @author System
 * @since 1.0.0
 */
@Mapper
public interface WorkdayConfigMapper extends BaseMapper<WorkdayConfig> {
    
    /**
     * 根据公司ID查找所有配置
     */
    @Select("SELECT * FROM workday_configs WHERE company_id = #{companyId} AND is_deleted = 0")
    List<WorkdayConfig> findByCompanyIdAndIsDeletedFalse(@Param("companyId") Long companyId);
    
    /**
     * 查找公司的默认配置
     */
    @Select("SELECT * FROM workday_configs WHERE company_id = #{companyId} AND is_default = 1 AND is_deleted = 0")
    WorkdayConfig findByCompanyIdAndIsDefaultTrueAndIsDeletedFalse(@Param("companyId") Long companyId);
    
    /**
     * 根据公司ID和配置名称查找
     */
    @Select("SELECT * FROM workday_configs WHERE company_id = #{companyId} AND config_name = #{configName} AND is_deleted = 0")
    WorkdayConfig findByCompanyIdAndConfigNameAndIsDeletedFalse(@Param("companyId") Long companyId, 
                                                               @Param("configName") String configName);
}
